﻿using System.Windows;
using Catel.Articles.Base.Data.Attributes;

namespace Catel.Articles._03___MVVM.Examples.ControlToViewModelWithWindow
{
    [Example("ControlToViewModelMapping with Window", "Example of the ControlToViewModelMapping with a Window",
        LongDescription = @"The ControlToViewModelMapping is very useful when you want to create a user control or window " +
    "with dependency properties that should be accessible to the outside, but should also communicate with the view model.",
        SourceFileName = "/Examples/ControlToViewModelWithWindow/WindowWithViewModelMappings.xaml.cs",
        ClickHandlerName = "ShowExample")]
    public class Example
    {
        /// <summary>
        /// Shows the example.
        /// </summary>
        private static void ShowExample()
        {
            // Create window
            WindowWithViewModelMappings window = new WindowWithViewModelMappings();
            
            // Show current value
            MessageBox.Show(string.Format("First name is '{0}'", window.FirstName));

            // Show window
            window.ShowDialog();

            // Show current value
            MessageBox.Show(string.Format("First name is '{0}'", window.FirstName));
        }
    }
}
